/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sistemas.sisgear.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Jean
 */
@Entity
@Table(name = "seccion")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Seccion.todosDePlantilla", query = "SELECT s FROM Seccion s JOIN s.idTemplate t WHERE t.idTemplate = :codigo"),
    @NamedQuery(name = "Seccion.findAll", query = "SELECT s FROM Seccion s"),
    @NamedQuery(name = "Seccion.findByIdSeccion", query = "SELECT s FROM Seccion s WHERE s.idSeccion = :idSeccion"),
    @NamedQuery(name = "Seccion.findByTipo", query = "SELECT s FROM Seccion s WHERE s.tipo = :tipo"),
    @NamedQuery(name = "Seccion.findByNivel", query = "SELECT s FROM Seccion s WHERE s.nivel = :nivel")})
public class Seccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 25)
    @Column(name = "idSeccion")
    private String idSeccion;
    @Size(max = 1)
    @Column(name = "tipo")
    private String tipo;
    @Size(max = 1)
    @Column(name = "nivel")
    private String nivel;
    @JoinColumn(name = "idTemplate", referencedColumnName = "idTemplate")
    @ManyToOne(optional = false)
    private Template idTemplate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSeccion")
    private List<Campo> campoList;

    public Seccion() {
    }

    public Seccion(String idSeccion, String tipo, String nivel,Template idTemplate, List<Campo> campoList) {
        this.idSeccion = idSeccion;
        this.tipo = tipo;
        this.nivel = nivel;
        this.idTemplate = idTemplate;
        this.campoList = campoList;
    }

    public Seccion(String tipo, String nivel) {
        this.tipo = tipo;
        this.nivel = nivel;
    }
    

    public Seccion(String idSeccion) {
        this.idSeccion = idSeccion;
    }

    public String getIdSeccion() {
        return idSeccion;
    }

    public void setIdSeccion(String idSeccion) {
        this.idSeccion = idSeccion;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public String getNivel() {
        return nivel;
    }

    public void setNivel(String nivel) {
        this.nivel = nivel;
    }

    public Template getIdTemplate() {
        return idTemplate;
    }

    public void setIdTemplate(Template idTemplate) {
        this.idTemplate = idTemplate;
    }

    @XmlTransient
    public List<Campo> getCampoList() {
        return campoList;
    }

    public void setCampoList(List<Campo> campoList) {
        this.campoList = campoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idSeccion != null ? idSeccion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Seccion)) {
            return false;
        }
        Seccion other = (Seccion) object;
        if ((this.idSeccion == null && other.idSeccion != null) || (this.idSeccion != null && !this.idSeccion.equals(other.idSeccion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sistemas.sisgear.entidades.Seccion[ idSeccion=" + idSeccion + " ]";
    }
    
}
